home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / Apple Game Sprockets / Examples / NetSprocketTest / NSTestApp.cp < prev    next >
Encoding:
Text File  |  1996-05-16  |  17.6 KB  |  690 lines  |  [TEXT/CWIE]

  1. /******************************************************************************
  2.  **                                                                              **
  3.  **     Module:        PPTestApp.cp                                             **                        
  4.  **                                                                              **
  5.  **                                                                              **
  6.  **     Purpose:     Test harness for PowerPlay                                 **            
  7.  **                                                                              **
  8.  **        Author:        Jamie Osborne                                              **
  9.  **                                                                              **
  10.  **     Copyright (C) 1996 Apple Computer, Inc.  All rights reserved.         **
  11.  **                                                                              **
  12.  **                                                                              **
  13.  *****************************************************************************/
  14.  
  15. #define VERBOSE 0
  16.  
  17. #include "NSTestApp.h"
  18. #include "CPlayerWindow.h"
  19. #include <LGrowZone.h>
  20. #include <LWindow.h>
  21. #include <PP_Messages.h>
  22. #include <PP_Resources.h>
  23. #include <PPobClasses.h>
  24. #include <UDrawingState.h>
  25. #include <UMemoryMgr.h>
  26. #include <URegistrar.h>
  27. #include <LEditField.h>
  28. #include <iostream>
  29. #include <sioux.h>
  30. #include <stdio.h>
  31. #include <UModalDialogs.h>
  32. #include <LArrayIterator.h>
  33. #include <LString.h>
  34.  
  35. #include <OpenTptAppleTalk.h>
  36.  
  37. #include <NetSprocket.h>
  38.  
  39. // put declarations for resource ids (ResIDTs) here
  40.  
  41. const CommandT    cmd_Advertise            = 2000;
  42. const CommandT    cmd_Join                = 2001;
  43. const CommandT    cmd_Unadvertise            = 2002;
  44. const CommandT    cmd_Start                = 2003;
  45. const CommandT    cmd_TestGroups            = 2004;
  46.  
  47. enum {kKeyboardState = 600, kGameStart, kGameEnd, kTestGroups};
  48. Boolean IsPressed(unsigned short k);
  49. pascal Boolean MyJoinRequestHandler(NSpGameReference inGame, 
  50.                             NSpJoinRequestMessage *inMessage, void* inContext,
  51.                             Str255 outReason);
  52.  
  53. const char *kJoinRequestString = "DirectX- the Road to Nowhere";
  54. Boolean gGameOver;
  55. // ===========================================================================
  56. //        • Main Program
  57. // ===========================================================================
  58.  
  59. pascal Boolean MyJoinRequestHandler(NSpGameReference inGame, 
  60.                             NSpJoinRequestMessage *inMessage, void* inContext,
  61.                             Str255 outReason)
  62. {
  63.     LString::CopyPStr("\pYou forgot to say 'Simon says.'", outReason);
  64.     
  65.     return BlocksAreEqual(inMessage->customData, kJoinRequestString,
  66.                         inMessage->customDataLen);
  67. }
  68.  
  69. void main(void)
  70. {
  71.     SIOUXSettings.autocloseonquit = true;
  72.     SIOUXSettings.asktosaveonclose = false;
  73.     SIOUXSettings.initializeTB = false;
  74.     SIOUXSettings.setupmenus = false;
  75.     SIOUXSettings.standalone = false;
  76.                                     // Set Debugging options
  77.     SetDebugThrow_(debugAction_SourceDebugger);
  78.     SetDebugSignal_(debugAction_SourceDebugger);
  79.     InitializeHeap(3);                // Initialize Memory Manager
  80.                                     // Parameter is number of Master Pointer
  81.                                     //   blocks to allocate
  82.     
  83.                                     // Initialize standard Toolbox managers
  84.     UQDGlobals::InitializeToolbox(&qd);
  85.     gGameOver = false;        
  86.     new LGrowZone(20000);            // Install a GrowZone function to catch
  87.                                     //    low memory situations.
  88.     PPTestApp    theApp;            // replace this with your App type
  89.     
  90.     theApp.Run();
  91. }
  92.  
  93.  
  94. // ---------------------------------------------------------------------------
  95. //        • CPPStarterApp             // replace this with your App type
  96. // ---------------------------------------------------------------------------
  97. //    Constructor
  98.  
  99. PPTestApp::PPTestApp()
  100. {
  101.     // Register functions to create core PowerPlant classes
  102.     bAdvertising = false;
  103.     bRunning = false;
  104.     mPlayerCount = 0;
  105.     theGame = NULL;
  106.     RegisterAllPPClasses();
  107.     URegistrar::RegisterClass(CPlayerWindow::class_ID,        CPlayerWindow::CreatePlayerWindowStream);
  108.     gPulseBit = 0;
  109.     
  110. //    Initialize our player list
  111.     CPlayerListComparator *theComparator = new CPlayerListComparator();
  112.     ThrowIfNULL_(theComparator);
  113.     mPlayerList = new LArray(sizeof(PlayerListItem), theComparator, true);
  114.     ThrowIfNULL_(mPlayerList);
  115.  
  116. }
  117.  
  118.  
  119. // ---------------------------------------------------------------------------
  120. //        • ~PPTestApp            // replace this with your App type
  121. // ---------------------------------------------------------------------------
  122. //    Destructor
  123. //
  124.  
  125. PPTestApp::~PPTestApp()
  126. {
  127. }
  128.  
  129. // ---------------------------------------------------------------------------
  130. //        • StartUp
  131. // ---------------------------------------------------------------------------
  132. //    This function lets you do something when the application starts up. 
  133. //    For example, you could issue your own new command, or respond to a system
  134. //  oDoc (open document) event.
  135.  
  136. void
  137. PPTestApp::StartUp()
  138. {
  139.     OSStatus err;
  140.     UInt32    choice = 0;
  141.     
  142.     ObeyCommand(cmd_New, nil);        // EXAMPLE, create a new window
  143.     
  144. //    Do some quick and dirty testing
  145.     cout << "Starting up" << endl;
  146.     err =  NSpInitialize(500, 200000, 100, 'foob', 20);
  147.     cout << "NSpInitialize: " << err << endl;
  148.     err = NSpInstallJoinRequestHandler(&MyJoinRequestHandler, NULL);
  149.     cout << "NSpInstallJoinRequestHandler returned " << err << endl;
  150.  
  151.  
  152. }
  153.  
  154.  
  155. Boolean IsPressed(unsigned short k)
  156. // k =  any keyboard scan code, 0-127
  157. {
  158.     KeyMap map;
  159.     unsigned char km[16];
  160.     
  161.     GetKeys(map);
  162.     BlockMove(map, km, 16);
  163.  
  164.     Boolean pressed;
  165.     pressed = ( ( km[k>>3] >> (k & 7) ) & 1);
  166.     
  167.     return pressed;
  168. }
  169. int gLastTickCount = 0;
  170.  
  171. void
  172. PPTestApp::ProcessNextEvent()
  173. {
  174.     EventRecord        macEvent;
  175.     NSpMessageHeader        *theMessage;
  176.     OSStatus    status;
  177.     if (IsOnDuty()) {
  178.             
  179.             // Calling OSEventAvail with a zero event mask will always
  180.             // pass back a null event. However, it fills the EventRecord
  181.             // with the information we need to set the cursor shape--
  182.             // the mouse location in global coordinates and the state
  183.             // of the modifier keys.
  184.             
  185.         ::OSEventAvail(0, &macEvent);
  186.         AdjustCursor(macEvent);
  187.     }
  188.     
  189.         // Retrieve the next event. Context switch could happen here.
  190.     
  191.     Boolean    gotEvent = ::WaitNextEvent(everyEvent, &macEvent, 0,
  192.                                         mMouseRgnH);
  193.  
  194.  
  195.     Boolean SIOUXDidEvent = SIOUXHandleOneEvent(&macEvent);
  196.     if (!SIOUXDidEvent)
  197.     {
  198.         SetUpdateCommandStatus(false);
  199.         
  200.             // Let Attachments process the event. Continue with normal
  201.             // event dispatching unless suppressed by an Attachment.
  202.  
  203.         if (LAttachable::ExecuteAttachments(msg_Event, &macEvent)) {
  204.             if (gotEvent) {
  205.                 DispatchEvent(macEvent);
  206.             } else {
  207.                 UseIdleTime(macEvent);
  208.             }
  209.         }
  210.     }
  211.                                         // Repeaters get time after every event
  212.     LPeriodical::DevoteTimeToRepeaters(macEvent);
  213.     
  214.                                     // Update status of menu items
  215.     if (IsOnDuty() && GetUpdateCommandStatus()) {
  216.         UpdateMenus();
  217.     }
  218.     
  219.     if (theGame && bRunning /*&& IsPressed(122)*/)
  220.     {
  221.         UInt32 count = TickCount();
  222.         if (count >= gLastTickCount)
  223.         {    
  224.             TKeyState    state;
  225.             
  226.             gLastTickCount = count + 3;
  227.             
  228.             NSpClearMessageHeader((NSpMessageHeader *)&state);
  229.             state.h.what = kKeyboardState;
  230.             state.h.to = kNSpAllPlayers;
  231.             state.h.messageLen = sizeof(TKeyState);
  232.             
  233.             state.keyMap[0] = IsPressed(0x7e) ? 1 : 0;
  234.             state.keyMap[1] = IsPressed(0x7d) ? 1 : 0;
  235.             state.keyMap[2] = IsPressed(0x7c) ? 1 : 0;
  236.             state.keyMap[3] = IsPressed(0x7b) ? 1 : 0;
  237.             state.pulseBit = gPulseBit;
  238.             gPulseBit = (gPulseBit == 1) ? 0 : 1;
  239.             
  240. //            if (state.keyMap[0] != 0)
  241. //                NSpMessage_Send(theGame, (NSpMessageHeader *) &state, kNSpSendFlag_Normal | kNSpSendFlag_SelfSend);    
  242.                 status = NSpMessage_SendTo(theGame, kNSpAllPlayers, 
  243.                     kKeyboardState, state.keyMap, 16, 
  244.                     kNSpSendFlag_Normal | kNSpSendFlag_SelfSend);
  245.  
  246.         }    
  247.     }
  248.     
  249.     if (theGame)
  250.     {
  251.         while ((theMessage = NSpMessage_Get(theGame)) != NULL)
  252.         {
  253.             HandleGameEvent(theMessage);
  254.             NSpMessage_Release(theGame, (NSpMessageHeader *)theMessage);
  255.             if (gGameOver)
  256.             {
  257.                 status = NSpGame_Dispose(theGame, 0);
  258.                 cout << "NSpGame_Dispose returned " << status << endl;
  259.                 theGame = NULL;
  260.                 bRunning = false;
  261.                 ObeyCommand(cmd_Quit, NULL);
  262.             }
  263.         }
  264.     }
  265.         
  266. }
  267.  
  268.  
  269. void PPTestApp::HandleGameEvent(NSpMessageHeader *inEvent)
  270. {
  271. #if VERBOSE
  272.     cout << "Handling event:";
  273.     cout << "\twhat = " << inEvent->what << endl;
  274.     cout << "\twhen = " << inEvent->when << endl;
  275.     cout << "\tfrom = " << inEvent->from << endl;
  276.     cout << "\tto = " << inEvent->to << endl;
  277.     cout << "\tid = " << inEvent->id << endl;
  278.     cout << "\tdataLen = " << inEvent->dataLen << endl;
  279.     cout << "\tcookie = " << inEvent->cookie << endl;
  280. #endif
  281.     switch (inEvent->what)
  282.     {
  283.         case kNSpJoinApproved:
  284.         break;
  285.         case kNSpJoinDenied:
  286.         break;
  287.         case kNSpPlayerJoined:
  288.             HandlePlayerJoined((NSpPlayerJoinedMessage *)inEvent);
  289.         break;
  290.         case kNSpPlayerLeft:
  291.             HandlePlayerLeft((NSpPlayerLeftMessage *)inEvent);
  292.         break;
  293.         case kKeyboardState:
  294.             HandleKeyboardState((TKeyState *)inEvent);
  295.         break;
  296.         case kGameStart:
  297.             HandleGameStart(inEvent);
  298.         break;
  299.         case kGameEnd:
  300.             HandleGameEnd(inEvent);
  301.         break;
  302.         case kTestGroups:
  303.             HandleTestGroups(inEvent);
  304.         break;
  305.         default:
  306.             cout << "Unhandled game event:" << inEvent->what << endl;
  307.         break;
  308.     }
  309. }
  310.  
  311. void PPTestApp::HandlePlayerJoined(NSpPlayerJoinedMessage *inEvent)
  312. {
  313.     PlayerListItem item;
  314.     NSpMessageHeader    theMessage;
  315.     OSStatus        status;
  316.     
  317.     cout << "In HandlePlayerJoined" << endl;
  318.  
  319.     if (inEvent->playerInfo.id == NSpPlayer_GetMyID(theGame))
  320.         return;
  321.         
  322.     if (bRunning)
  323.     {
  324.         if (bHost)
  325.         {
  326.             NSpClearMessageHeader(&theMessage);
  327.             theMessage.what = kGameStart;
  328.             theMessage.to = inEvent->playerInfo.id;
  329.             theMessage.messageLen = sizeof(NSpMessageHeader);
  330.             
  331.             status = NSpMessage_Send(theGame, &theMessage, kNSpSendFlag_Registered);
  332.             ThrowIfOSErr_(status);
  333.         }
  334.         
  335.         LWindow *window = LWindow::CreateWindow(1002, this);
  336.         window->SetDescriptor(inEvent->playerInfo.name);
  337.         window->Show();
  338.         item.player = inEvent->playerInfo.id;
  339.         item.window = window;
  340.         mPlayerList->InsertItemsAt(1, 0, &item);
  341.     }
  342.     
  343. }
  344.  
  345. void PPTestApp::HandlePlayerLeft(NSpPlayerLeftMessage *inEvent)
  346. {
  347.     cout << "In HandlePlayerLeft" << endl;
  348.     
  349.     ArrayIndexT    index = mPlayerList->FetchIndexOfKey(&inEvent->playerID);
  350.     PlayerListItem item;
  351.     if (mPlayerList->FetchItemAt(index, &item))
  352.         item.window->DoClose();
  353.     
  354.     mPlayerCount--;
  355. }
  356.  
  357. void PPTestApp::HandleGameStart(NSpMessageHeader *inEvent)
  358. {
  359.     UInt32    i;
  360.     LWindow    *window;
  361.     bRunning = true;
  362.     PlayerListItem item;
  363.     LStr255    title;
  364.     OSStatus    err;
  365.     
  366.     NSpPlayerEnumerationPtr     thePlayers;
  367.     NSpPlayerInfoPtr    playerInfo;
  368.             
  369.     err = NSpPlayer_GetEnumeration(theGame, &thePlayers);
  370.     if (err == noErr)
  371.     {
  372.         for (i = 0; i < thePlayers->count; i++)
  373.         {
  374.             playerInfo = thePlayers->playerInfo[i];
  375.             window = LWindow::CreateWindow(1002, this);
  376.             window->SetDescriptor(playerInfo->name);
  377.             window->Show();
  378.             item.player = playerInfo->id;
  379.             item.window = window;
  380.             
  381.             mPlayerList->InsertItemsAt(1, 0, &item);
  382.             
  383.         }
  384.         
  385.         NSpPlayer_ReleaseEnumeration(theGame, thePlayers);
  386.     }
  387.     else
  388.         cout << "NSpPlayer_GetEnumeration returned " << err << endl;
  389. }
  390.  
  391. void PPTestApp::HandleGamePause(NSpMessageHeader *inEvent)
  392. {
  393.     cout << "In HandleGamePause" << endl;
  394. }
  395.  
  396. void PPTestApp::HandleGameEnd(NSpMessageHeader *inEvent)
  397. {
  398.     cout << "In HandleGameEnd" << endl;
  399.     PlayerListItem item;
  400.     LArrayIterator     iter(*mPlayerList);
  401.     
  402.     while(iter.Next(&item))
  403.     {
  404.         item.window->DoClose();
  405.         mPlayerList->Remove(&item);
  406.     }    
  407.     
  408.     gGameOver = true;
  409. }
  410.  
  411. void PPTestApp::HandleTestGroups(NSpMessageHeader *inEvent)
  412. {
  413.     cout << "\t!!Received a message to group " << inEvent->to << endl;
  414. }
  415.  
  416. void PPTestApp::HandleKeyboardState(TKeyState *inEvent)
  417. {
  418.     PlayerListItem info;
  419.     ArrayIndexT    index;
  420.             
  421.     UInt32    time = NSpGetCurrentTimeStamp(theGame)/* - inEvent->h.when*/;
  422.     index = mPlayerList->FetchIndexOfKey(&inEvent->h.from);
  423. #if DEBUG
  424.     if (index == LArray::index_Bad)
  425.         cout << "Got a bad player list index in HandleKeyboardState" << endl;
  426. #endif
  427.     if (mPlayerList->FetchItemAt(index, &info))
  428.     {
  429.         CPlayerWindow *theWindow = (CPlayerWindow *)info.window;
  430.         
  431.         if (theWindow)
  432.         {
  433.             theWindow->mUp = inEvent->keyMap[0];
  434.             theWindow->mDown = inEvent->keyMap[1];
  435.             theWindow->mLeft = inEvent->keyMap[2];
  436.             theWindow->mRight = inEvent->keyMap[3];
  437.             theWindow->mPulse = inEvent->pulseBit;
  438.             theWindow->mTransitTime = time;
  439.             theWindow->Refresh();
  440.         }
  441.     }
  442. }
  443.  
  444.  
  445. // ---------------------------------------------------------------------------
  446. //        • ObeyCommand
  447. // ---------------------------------------------------------------------------
  448. //    Respond to commands
  449.  
  450. NSpProtocolListReference    theList;
  451.  
  452. Boolean
  453. PPTestApp::ObeyCommand(
  454.     CommandT    inCommand,
  455.     void        *ioParam)
  456. {
  457.     Boolean        cmdHandled = true;
  458.     OSStatus        err = noErr;
  459.     Str255 name;
  460.     Str255 password;
  461.     Str255 gameName;
  462.     UInt16    port = 3333;
  463.     NSpMessageHeader theMessage;
  464.     
  465.     switch (inCommand) {
  466.     
  467.         // Deal with command messages (defined in PP_Messages.h).
  468.         // Any that you don't handle will be passed to LApplication
  469.              
  470.         case cmd_Advertise:
  471.         {
  472.             UInt32 protocols = 0;
  473.             LString::CopyPStr("\pTest1", gameName);
  474.             LString::CopyPStr("\pbarney", password);
  475.             LString::CopyPStr("\pDarmok", name);
  476.  
  477.             NSpProtocolListReference    theList;
  478.  
  479.             NSpProtocolReference theRef = NSpProtocol_CreateAppleTalk(gameName, "\pbandersnatch", 10000, 1);    
  480.             
  481.             err = NSpProtocolList_New(theRef, &theList);
  482.             if (err != noErr)
  483.             {
  484.                 cout << "NSpProtocolListRef_New returned an error! " << err << endl;
  485.                 return true;
  486.             }
  487.             
  488.             if (!NSpDoModalHostDialog(theList, gameName, name, password, NULL))
  489.                 return true;
  490.             err = NSpGame_Host(&theGame, theList, 12, gameName, password, name, 0, kNSpClientServer, 0);
  491.             if (err != noErr)
  492.             {
  493.                 cout << "NSpGame_New returned an error! " << err << endl;
  494.                 return true;
  495.             }
  496.             
  497.             bAdvertising = true;
  498.             bHost = true;
  499.         }
  500.         break;
  501.         case cmd_Unadvertise:
  502.             if (bAdvertising)
  503.             {
  504. //                err = NSpGame_EnableAdvertising(theGame, theList);
  505.                 cout << "NSpGame_StopHosting game (expect 0): " << err << endl;
  506.                 
  507.                 NSpProtocolList_Dispose(theList);
  508.                 
  509.                 if (err == noErr)
  510.                     bAdvertising = false;
  511.             }
  512.         break;
  513.         case cmd_Join:
  514.         {
  515.             NSpAddressReference theAddress;
  516.             LString::CopyPStr("\pDarmok", name);
  517.             LString::CopyPStr("\pbarney", password);
  518.  
  519.             theAddress = NSpDoModalJoinDialog("\pbandersnatch", "\pGame servers:", name, password, NULL);
  520.             cout << "DoModalJoinWithName returned an address ref of " << theAddress << endl;
  521.             if (theAddress != NULL)
  522.             {
  523.                 err = NSpGame_Join(&theGame, theAddress, name, password, 0, (void*) kJoinRequestString, 28,0);
  524.                                     
  525.                 cout << "NSpGame_Join returned err: " << err << endl;
  526.                 NSpReleaseAddressReference(theAddress);
  527.             }
  528.             bHost = false;
  529.             bAdvertising = false;
  530.         }
  531.         break;
  532.         case cmd_Start:
  533.             NSpClearMessageHeader(&theMessage);
  534.             theMessage.what = kGameStart;
  535.             theMessage.to = 0;
  536.             theMessage.messageLen = sizeof(NSpMessageHeader);
  537.             
  538.             NSpMessage_Send(theGame, &theMessage, kNSpSendFlag_Registered | kNSpSendFlag_SelfSend);
  539. //            bRunning = true;
  540.             
  541.         break;
  542.         case cmd_TestGroups:
  543.             NSpGroupID theGroup;
  544.             NSpClearMessageHeader(&theMessage);
  545.             theMessage.what = kTestGroups;
  546.             theMessage.messageLen = sizeof(NSpMessageHeader);
  547.             
  548.             err = NSpGroup_New(theGame, &theGroup);
  549.             cout << "NSpGroup_New returned: " << err << endl;
  550.             if (!err)
  551.                 cout << "\tCreated group number " << theGroup << endl;
  552.  
  553.             theMessage.to = theGroup;
  554.                             
  555.             err = NSpGroup_AddPlayer(theGame, theGroup, 1);
  556.             cout << "NSpGroup_AddPlayer returned " << err << endl;
  557.         
  558.             err = NSpMessage_Send(theGame, &theMessage, kNSpSendFlag_Registered);
  559.             
  560.             err = NSpGroup_AddPlayer(theGame, theGroup, 2);
  561.             cout << "NSpGroup_AddPlayer returned " << err << endl;
  562.  
  563.             err = NSpMessage_Send(theGame, &theMessage, kNSpSendFlag_Registered);
  564.  
  565.             err = NSpGroup_RemovePlayer(theGame, theGroup, 1);
  566.             cout << "NSpGroup_RemovePlayer returned " << err << endl;
  567.             
  568.             err = NSpMessage_Send(theGame, &theMessage, kNSpSendFlag_Registered);
  569.  
  570.             err = NSpGroup_Dispose(theGame, theGroup);
  571.             cout << "NSpGroup_Dispose returned: " << err << endl;
  572.             if (!err)
  573.                 cout << "\tDeleted group number " << theGroup << endl;
  574.  
  575.             err = NSpGroup_AddPlayer(theGame, theGroup, 2);
  576.             cout << "NSpGroup_AddPlayer returned (should be err)" << err << endl;
  577.  
  578.         break;            
  579.         case cmd_Quit:
  580.             if (theGame)
  581.             {
  582.                 if (bHost)
  583.                 {
  584.                     NSpClearMessageHeader(&theMessage);
  585.                     theMessage.what = kGameEnd;
  586.                     theMessage.to = 0;
  587.                     theMessage.messageLen = sizeof(NSpMessageHeader);
  588.                     
  589.                     NSpMessage_Send(theGame, &theMessage, kNSpSendFlag_Registered);
  590.                 }
  591.                 NSpGame_Dispose(theGame, kNSpGameFlag_ForceTerminateGame);
  592.                 theGame = NULL;
  593.             }
  594.             bRunning = false;
  595.             LApplication::ObeyCommand(inCommand, ioParam);
  596.         default:
  597.             cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
  598.             break;
  599.     }
  600.     
  601.     return cmdHandled;
  602. }
  603.  
  604. // ---------------------------------------------------------------------------
  605. //        • FindCommandStatus
  606. // ---------------------------------------------------------------------------
  607. //    This function enables menu commands.
  608. //
  609.  
  610. void
  611. PPTestApp::FindCommandStatus(
  612.     CommandT    inCommand,
  613.     Boolean        &outEnabled,
  614.     Boolean        &outUsesMark,
  615.     Char16        &outMark,
  616.     Str255        outName)
  617. {
  618.  
  619.     switch (inCommand) {
  620.     
  621.         // Return menu item status according to command messages.
  622.         // Any that you don't handle will be passed to LApplication
  623.  
  624.         case cmd_Advertise:
  625.             outEnabled = true;
  626.         break;
  627.         case cmd_Unadvertise:
  628.             if (bAdvertising == true)
  629.                 outEnabled = true;
  630.             else
  631.                 outEnabled = false;
  632.         break;
  633.         case cmd_Join:
  634.             outEnabled = true;
  635.         break;
  636.         case cmd_Start:
  637.                 outEnabled = true;
  638.         break;
  639.         case cmd_TestGroups:
  640.             outEnabled = true;
  641.         break;
  642.         default:
  643.             LApplication::FindCommandStatus(inCommand, outEnabled,
  644.                                                 outUsesMark, outMark, outName);
  645.             break;
  646.     }
  647. }
  648.  
  649.  
  650. Int32
  651. CPlayerListComparator::Compare(
  652.     const void*        inItemOne,
  653.     const void*        inItemTwo,
  654.     Uint32            /* inSizeOne */,
  655.     Uint32            /* inSizeTwo */) const
  656. {
  657.     return ( (((PlayerListItem *)inItemOne)->player) - (((PlayerListItem *)inItemTwo)->player) );
  658. }
  659.  
  660.  
  661. Boolean
  662. CPlayerListComparator::IsEqualTo(
  663.     const void*        inItemOne,
  664.     const void*        inItemTwo,
  665.     Uint32            /* inSizeOne */,
  666.     Uint32            /* inSizeTwo */) const
  667. {
  668.     return ( (((PlayerListItem *)inItemOne)->player) == (((PlayerListItem *)inItemTwo)->player) );
  669. }
  670.  
  671.  
  672. Int32
  673. CPlayerListComparator::CompareToKey(
  674.     const void*         inItem ,
  675.     Uint32            /* inSize */,
  676.     const void*         inKey ) const
  677. {
  678.     return ( (((PlayerListItem *)inItem)->player) - (*(NSpPlayerID *)inKey) );
  679. }
  680.                                 
  681.  
  682. Boolean
  683. CPlayerListComparator::IsEqualToKey(
  684.     const void*        inItem,
  685.     Uint32            inSize,
  686.     const void*        inKey) const
  687. {
  688.     return ( (((PlayerListItem *)inItem)->player) == (*(NSpPlayerID *)inKey) );
  689. }
  690.